<!DOCTYPE html>
<html lang="en">
<head>
    <title>角色</title>
	<#include "../common.ftl" />
    <link href="${ticket.contextPath}/static/common/css/datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">

    <script type="text/javascript" src="${ticket.contextPath}/static/common/js/datetimepicker/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="${ticket.contextPath}/static/common/js/datetimepicker/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
</head>
<body>
<div class="container">
    <form id="userForm"  enctype="multipart/form-data"  style="max-width: 350px;margin: 0 auto;margin-top: 20%;">
        <input type="hidden" id="id" name="id" value="${(role.id)!}" />
        <div class="form-group">
            <label for="inputForName">名称</label>
            <input type="text" class="form-control" id="inputForName" name="name" placeholder="姓名" value="${(role.name)!}">
        </div>
        <div class="form-group">
            <label for="inputTips">提示</label>
            <input type="text" class="form-control" id="inputTips" name="tips" placeholder="tips" value="${(role.tips)!}">
        </div>
        <div class="form-group">
            <label for="inputPid">上级角色</label>
            <select class="form-control" id="inputPid" name="pid">
                <#if !(roleList)?? >
                    <option value="0">超级管理员</option>
                </#if>
                <#list roleList as role>
                    <option value="${(role.id)!0}">${(role.name)!}</option>
                </#list>
            </select>
        </div>
        <#--<div class="form-group">
            <label for="inputVersion">备注</label>
            <input type="text" class="form-control" id="inputVersion" name="version" placeholder="version" value="${(role.version)!}">
        </div>-->
        <button type="button" onclick="subForm()" class="btn btn-default">修改</button>
    </form>

</div>
<script>
    $(window.parent.document).find("#myiframe").load(function(){
        var main = $(window.parent.document).find("#myiframe").height();
        $("#bbb").height(main);
    });

    function subForm(){
        var url="/admin/role";
        var form = $("#userForm");
        var formData = new FormData(document.getElementById("userForm"));
        $.ajax({
            type:'POST',
            url:url,
            processData:false,
            contentType:false,
            cache: false,
            data:formData,
            success:function(data){
                if(data == "success"){
                    window.location.href = "/admin/roles"
                }
            },
            error:function(err){
                var ss = JSON.stringify(err)
                alert(ss)
            }
        })
    }
</script>
</body>
</html>